//
//  StatusesFowardCell.swift
//  Microblog
//
//  Created by steaest on 15/8/8.
//  Copyright © 2015年 steaest. All rights reserved.
//

import UIKit

class StatusesFowardCell: StatusesCell {
    
    override var statuses: Status? {
        didSet {
            let userName = statuses?.retweeted_status?.user?.name ?? ""
            let text = statuses?.retweeted_status?.text ?? ""
            
            forwardLabel.text = userName + ":" + text
        }
    }
    
    override func setupUI() {
        super.setupUI()
        
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.insertSubview(forwardLabel, aboveSubview: backButton)
        
        forwardLabel.text = "hahahahahwanmgkjsdfbbsdfglsd,fnbldsgflsdkkbfjsdbjkdcvzcmncmnzbcnmzbc"
        
        //自动布局
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -StatusesCellMargin, y: StatusesCellMargin))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: StatusesCellMargin, y: StatusesCellMargin))
        
        //图片
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: StatusesCellMargin))
        pictureWidthCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureHeightCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureTopCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)

        
    }

    //MARK:懒加载控件
    private lazy var backButton: UIButton = {
        
        let btn = UIButton()
        btn.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        
        return btn
    }()
    //转发文字
    private lazy var forwardLabel: UILabel = {
        
        let label = UILabel(color: UIColor.darkGrayColor(), fontSize: 14)
        label.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.size.width - 2 * StatusesCellMargin
        label.numberOfLines = 0
        
        return label
    }()
}
